1. Field of the Invention
The present invention relates to a method for compressing an image, more particularly, to a method for compressing an image by classifying colors to decrease amounts of data and increase amounts of the image data saved in the memory.
2. Description of the Prior Art
For present information users, especially to the personal computer users, a mode of the computer information has been changed from an unexciting word mode to a multi-media mode. The multi-media mode means that the information comprises words, images, and sounds. In order to show the multi-media mode in the face of viewers, various multi-media devices, which can collect the images and sounds, are developed. Because the multi-media information comprises more matters, memories, which are used to deal with the multi-media information, are greater than memories, which are used to deal with the unexciting word information to show the multi-media information more smoothly.
For an input image device, scanners and digital cameras are the common devices at the present day. The digital camera uses digital information to save the image, which is got from shooting a scene on a location. It uses a floppy disk card or a personal computer memory card international association (PCMCIA) card to save a static image. In order to decrease the memory of saving multi-media information, the images, which is got from shooting a scene on a location by using a digital camera, are saved by using compression files. The file format of a joint photographic experts group (JPEG) mode is common used in the static image compression files.
A photo, which is taken by using a digital camera, can be transmitted to the computer to proceed an image process by using a RS-232 communication port or a printer port. The photo also can be printed by using a printer and can not be showed by using the traditional developing and printing method. Getting the photo further has no problems in fixing a negative. Therefore, the digital camera is very suitable for reporters, who usually compete with time, because the digital camera can transmit the photo to become a file directly and then the file can be transmitted to newspaper office by using an electronic mail. At present, a dpi of the digital camera has several differences to a dpi of a traditional camera, which uses a negative. Especially when a light source of a place is not enough, the dpi of the digital camera is not being quite as good as the traditional camera. But there is a liquid crystal display (LCD) usually fixed in the digital, the photo image data can be previewed and deleted by using the LCD. This is a characteristic of the digital camera and is different from the traditional camera.
The other name of the digital is “digital still camera; DSC” to be differentiated from a digital dynamic camera. At present, most digital cameras use a charge-coupled device (CCD) or a complementary metal-oxide semiconductor (CMOS) to get a photo image data.
Referring to FIGS. 1A and 1B, this shows a diagram in an image, which is got from the traditional technology and is before transmitted. FIG. 1A shows how to choose R (red), G (green), and B (blue) at a beginning area of a digital image data. In FIG. 1A, each block expresses one color information of a pixel in the digital image area. The number, which is in the block, expresses the location of the pixel in the digital image area. In the specification of the present invention, the signal P(x, y) expresses the image information-pixel value, wherein the signal x expresses a serial number of lines and the signal y expresses a serial number of the pixel on a line. For example, the signal P(2n−1, 1) expresses a pixel value, which is the first pixel of the 2n−1 line, wherein the signal n is a natural number.
FIG. 1B shows a condition of R, G, and B, which corresponds to each pixel. In FIG. 1B, the signals R(x, y), G(x, y), and B(x, y) individually express the colored information of the pixel P(x, y). If each pixel of R, G, and B is expressed in 8 bits, the data amount of each pixel is 3*8=24 bits.
From FIG. 1A and FIG. 1B, when the traditional scanner transmits the image data to the personal computer, all of R, G, and B of each pixel are transmitted. The image data, which will be transmitted, will be saved in a buffer of the digital camera at first. When the buffer is full, the buffer will transmit the data, which are saved in it, to a memory card of the digital camera to be saved. In general, occupied memory space of pixels is very huge. Therefore, if all of the R, G, and B of each pixel are saved in the memory card without compression procedure, the memory card will be often full and this condition will cause troubles for the user. When the amount of image data is greater, the memory card full conditions are more and the using time of the memory card is shorter. The lifetime of the memory card is also decreased. The memory card, whose all space is saved data, of the digital camera can be replaced by a new memory card to increase saving image data of the digital camera following needs of the user. But this condition will increase the cost of the user more easily. Therefore, compressing image data suitably will increase the photo image data of the memory card of the digital camera.